package com.whoimi.admin.rest;

import com.whoimi.admin.entity.DictItem;
import com.whoimi.admin.service.DictItemService;
import com.whoimi.common.ResultInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author whoimi
 * @since 2025-08-01
 **/
@RestController
@RequestMapping("/api/v1/dicts")
class DictRest {
    @Resource
    private DictItemService dictItemService;

    /**
     * 字典项列表
     */
    @GetMapping("/{dictCode}/items")
    public ResultInfo<Iterable<DictItem>> getDictItems(@PathVariable String dictCode) {
        Iterable<DictItem> items = dictItemService.findAllByDictCodeAndStatusIsTrueOrderBySortAsc(dictCode);
        return ResultInfo.ok(items);
    }
}
